#ifndef _LJMU_DX10_SSPRITE_H_
#define _LJMU_DX10_SSPRITE_H_

#include "util_texture.h"
#include <string>

class LJMUUtilComplexSprite
{
private:
	struct SpriteVertexType
	{
		D3DXVECTOR3 screenpos;
	    D3DXVECTOR2 textureuv;
	};

public:
	//--------------CONSTRUCTORS/DESTRUCTORS------------------------------------
	LJMUUtilComplexSprite(): _obj_buff_vertex(NULL),_obj_buff_index(NULL),_obj_dx_texture(NULL),_obj_dx_device(NULL){};
	~LJMUUtilComplexSprite(){};

	//--------------ACCESSORS/MUTATORS------------------------------------------
	int							getIndexCount();
	ID3D10ShaderResourceView*	getTexture();
	int							getWidth();
	int							getHeight();
	int							getHalfWidth();
	int							getHalfHeight();
	int							getImageWidth();

	//--------------PUBLIC METHODS----------------------------------------------
	virtual bool initialise(ID3D10Device* pdevice,std::wstring ptexfilename, int pspritewidth, int pspriteheight,int pnocells);
	virtual void cleanup();
	virtual bool render();

protected:
	//--------------PRIVATE METHODS---------------------------------------------
	bool internLoadTextureInMem(ID3D10Device* pdevice,std::wstring ptexfilename);
	void internReleaseTextureFromMem();

protected:
	//--------------INTERNAL FIELDS----------------------------------------------
	ID3D10Device*		_obj_dx_device;
	LJMUUtilTexture*	_obj_dx_texture;
	ID3D10Buffer*		_obj_buff_vertex;
	ID3D10Buffer*		_obj_buff_index;
	int					_vertex_count;
	int					_index_count;
	int					_sprite_width;
	int					_sprite_height;
	int					_image_width;
	int					_no_cells;
	
};

//----------------INLINE GETTERS AND SETTERS-------------------------------------

/*******************************************
* Get the Number of Indices in this Object.
*******************************************/
inline int LJMUUtilComplexSprite::getIndexCount()
{
	return this->_index_count;
}

/*******************************************
* Get the Number of Indices in this Object.
*******************************************/
inline int LJMUUtilComplexSprite::getWidth()
{
	return this->_sprite_width;
}

/*******************************************
* Get the Number of Indices in this Object.
*******************************************/
inline int LJMUUtilComplexSprite::getHalfWidth()
{
	return this->_sprite_width/2;
}

/*******************************************
* Get the Number of Indices in this Object.
*******************************************/
inline int LJMUUtilComplexSprite::getHeight()
{
	return this->_sprite_height;
}

/*******************************************
* Get the Number of Indices in this Object.
*******************************************/
inline int LJMUUtilComplexSprite::getHalfHeight()
{
	return this->_sprite_height /2;
}

/*******************************************
*
*******************************************/
inline int LJMUUtilComplexSprite::getImageWidth()
{
	return this->_image_width;
}

/*******************************************
* Get a Reference to the Texture of the
* Sprite.
*******************************************/
inline ID3D10ShaderResourceView* LJMUUtilComplexSprite::getTexture()
{
	return this->_obj_dx_texture->getTexture();
}

#endif